<!-- tabbar.vue -->
<template>
  <view class="bg-#f4f6fc h-vh">
    <view class="pb-8vh overflow-scroll pos-relative box-border">
      <slot></slot>
    </view>
  </view>
  <view class="pos-fixed pos-bottom-4 w-100% bg-#f4f6fc">
    <wd-tabbar shape="round" v-model="tabbar" @change="redirectRouteTo">
      <wd-tabbar-item title="首页" icon="home"></wd-tabbar-item>
      <wd-tabbar-item title="我的" icon="user"></wd-tabbar-item>
    </wd-tabbar>
  </view>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
uni.hideHomeButton()
const tabbar = ref(1)
const data = [
  { url: '/pages/home/company-home/index', index: 0 },

  {
    url: '/pages/my/company-my/index',
    index: 1
  }
]
const setTabBar = () => {
  tabbar.value = data.find(item => item.url === '/' + getCurrentPages()[0].route)?.index
}
setTabBar()
const redirectRouteTo = index => {
  let url = data.find(item => item.index === index.value).url
  uni.switchTab({
    url: url
  })
  setTabBar()
}
</script>
